package com.exam.controller;

import com.exam.dto.ActionResult;
import com.exam.po.FillQuestion;
import com.exam.service.FillQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author mahaoqi
 * @ClassName FillQuestionController
 * @Description TODO
 * @Date 2021/1/11 20:44
 * @Version 1.0
 **/
@RestController
@RequestMapping("/api")
public class FillQuestionController {

    @Autowired
    private FillQuestionService QuestionService;

    /**
     *
     * 增加
     * @param record
     * @return
     */
    @RequestMapping(value = "/fillQuestion",method = RequestMethod.POST)
    @ResponseBody
    public ActionResult AddFill(@RequestBody FillQuestion record){
       //System.out.println(record);

        int insert = QuestionService.Insert(record);
        //System.out.println("***"+insert);
        if (insert>-1){
            //System.out.println("1");
            ActionResult success = new ActionResult(200, "success", insert);
            return success;
        }else{
            //System.out.println("2");
            ActionResult error = new ActionResult(203, "error", null);
            return error;
        }
    }

    /**
     * 查看
     * @param questionid
     * @return
     */
    @RequestMapping(value = "/fillQuestionId",method = RequestMethod.GET)
    public ActionResult FindFillquest(Integer questionid){
        FillQuestion fillQuestion = QuestionService.SelectByPrimaryKey(questionid);
        if (fillQuestion != null){
            ActionResult success = new ActionResult(200, "success", fillQuestion);
            return success;
        }else{
            ActionResult error = new ActionResult(203, "error", null);
            return error;
        }
    }
}
